//
//  AFNetworkServices.h
//  YLNetworkingFrameworks
//
//  Created by Topsun on 16/6/2.
//  Copyright © 2016年 tcl. All rights reserved.
//

#import <Foundation/Foundation.h>

@class AFNetResponse;
@class AFNetRequest;
@class AFNetworkServices;

typedef void (^ResultHandler)(AFNetRequest *netRequest, AFNetResponse *netResponse, NSError *error);

// 进度的状态
typedef NS_ENUM(NSInteger , XProgressStat)
{
    eStart,                 // 开始准备发起http请求，还未设置参数
    eDoneParameter,         // 参数设置完成
    eDoneRequest,           // http请求完成
    eRequestComplete        // 当前NetRequest请求事件完成
};

// NetWorkServices处理NetRequest进度接口
@protocol NetWorkServicesInterface <NSObject>

- (void) netWorkServices:(AFNetworkServices*) netWorkServices         // 当前处理NetRequest对象的NetWorkServices
     startSendNetRequest:(AFNetRequest*) netRequest                   // 正在出来的NetRequest对象
            ProgressStat:(XProgressStat) stat                       // 当前进度状态
            additionInfo:(NSObject*) additionInfo;                  // 附加参数，不同进度状态下，参数值有所不同

@end

@interface AFNetworkServices : NSObject

+ (AFNetworkServices*) defaultNetWorkServices;


/**
 *  @author 李悦麟, 16-05-31
 *
 *  发送一个异步网络请求
 *
 *  @param netRequest  请求对象
 *  @param userInfo    自定义数据结构，请求完成后将返回给用户
 *
 *  @return 发送成功返回YES，否则NO
 *
 *  @since 1.0
 */
- (BOOL) sendRequest:(AFNetRequest*) netRequest
         resultBlock:(ResultHandler)resultHandler;

//添加监听
- (void) addInterfaceLister:(id<NetWorkServicesInterface>) interface;
//移除监听
- (void) removeInterfaceLister:(id<NetWorkServicesInterface>) interface;

@end

#ifndef NWS
#define NWS [AFNetworkServices defaultNetWorkServices]
#endif
